﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SAPPDI.Entitys;
using TestImpresion.Annotations;
using TestImpresion.Clases.Comunes;
using TestImpresion.Clases.Listas;

namespace TestImpresion.Clases
{
    public class InsertosFormulario : INotifyPropertyChanged
    {
        private Insertos _currentInsertos;

        public Insertos CurrentInsertos
        {
            get
            {
                return _currentInsertos;
            }
            set
            {
                if (_currentInsertos != null)
                {
                    _currentInsertos.PropertyChanged -= _currentInsertos_PropertyChanged;
                }
                _currentInsertos = value;
                _currentInsertos.PropertyChanged += _currentInsertos_PropertyChanged;
                NotifyPropertyChanged("CurrentInsertos");
            }
        }
        public FormularioBase Parent { get; set; }

        private void _currentInsertos_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
        }

        private ComparPorFormulario _comprarInsertosFormulario;
        public ComparPorFormulario ComprarInsertosFormulario
        {
            get
            {
                return _comprarInsertosFormulario;
            }
            set
            {
                if (_comprarInsertosFormulario != null)
                {
                    _comprarInsertosFormulario.PropertyChanged -= _comprarInsertosFormulario_PropertyChanged;
                }
                _comprarInsertosFormulario = value;
                _comprarInsertosFormulario.PropertyChanged += _comprarInsertosFormulario_PropertyChanged;
                NotifyPropertyChanged("ComprarInsertosFormulario");
            }
        }

        private void _comprarInsertosFormulario_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {

        }

        private ObservableCollection<Insertos> _listaInsertos = new ObservableCollection<Insertos>();

        public ObservableCollection<Insertos> ListaInsertos
        {
            get { return _listaInsertos; }
            set { _listaInsertos = value; }
        }


        private ObservableCollection<ComparPorFormulario> _listaComprarPor = new ObservableCollection<ComparPorFormulario>();

        public ObservableCollection<ComparPorFormulario> ListaComprarPor
        {
            get { return _listaComprarPor; }
            set { _listaComprarPor = value; }
        }

        public InsertosFormulario()
        {
            var datos = new DatosCombos();
            this.CurrentInsertos = new Insertos { TipoPapels = datos.ObtenTiposPapel(), 
                ListaEntrePliegos = datos.GetEntreQuePliegos() };
            this._comprarInsertosFormulario = new ComparPorFormulario();
        }

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
